﻿using System;

namespace Chisel.Core
{
    /// <summary>
    /// Possible interaction states of actors.
    /// </summary>
    [Flags]
    public enum ActorStateFlag { None = 0, Selected = 1, Hovering = 2, Dragging = 4 }

    /// <summary>
    /// This structure stores the interaction state of an actor.
    /// </summary>
    public class ActorState
    {
        private ActorStateFlag _internal;
        /// <summary>
        /// The internal state storage.
        /// </summary>
        public ActorStateFlag Flags
        {
            get { return _internal; }
        }

        public bool IsHovering
        {
            get { return (_internal & ActorStateFlag.Hovering) == ActorStateFlag.Hovering; }
            set
            {
                if (value)
                    _internal |= ActorStateFlag.Hovering;
                else
                    _internal &= ~ActorStateFlag.Hovering;
            }
        }

        public bool IsSelected
        {
            get { return (_internal & ActorStateFlag.Selected) == ActorStateFlag.Selected; }
            set
            {
                if (value)
                    _internal |= ActorStateFlag.Selected;
                else
                    _internal &= ~ActorStateFlag.Selected;
            }
        }

        public bool IsDragging
        {
            get { return (_internal & ActorStateFlag.Dragging) == ActorStateFlag.Dragging; }
            set
            {
                if (value)
                    _internal |= ActorStateFlag.Dragging;
                else
                    _internal &= ~ActorStateFlag.Dragging;
            }
        }

    }
}
